﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using TestesFixacao.Dominio.Modelos;

namespace TestesFixacao.Dominio.Writers
{
    public class QuestaoWriter : IConvertible<List<Questao>>
    {
        private AlternativaWriter _alternativaWriter;

        public QuestaoWriter(AlternativaWriter alternativaWriter)
        {
            _alternativaWriter = alternativaWriter;
        }

        public void Convert(XmlTextWriter writer, List<Questao> questoes)
        {
            writer.WriteStartElement("questoes");

            foreach (var item in questoes)
            {
                writer.WriteStartElement("alternativa");

                writer.WriteElementString("enunciado", item.Enunciado);
                writer.WriteElementString("bimestre", item.Bimestre.ToString());
                //writer.WriteElementString("materia", item.Materia.Nome);
                writer.WriteElementString("numero", item.Numero.ToString());

                _alternativaWriter.Convert(writer, item.Alternativas);

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
    }
}
